import numpy as np
import time
from functools import wraps

def fn_timer(function):
    @wraps(function)
    def function_timer(*args, **kwargs):
        t0 = time.time()
        result = function(*args, **kwargs)
        t1 = time.time()
        print("Total time running :" + str(t1 - t0)+"seconds" )
        return result
    return function_timer

@fn_timer
def bubble_sort(old):
    while old:
        flag = 0
        for i in range(len(old)):
            if i < len(old)-1:
                if old[i+1] < old[i]:
                    old[i],old[i+1] = old[i+1],old[i]
                    flag+=1
        if flag == 0 :
            break
    return old

if __name__ == '__main__':
    # old = [1, 56, 84, 23, 1, 5, 78, 3, 9, 2]
    new = np.random.randint(0, 100, 100)
    look = bubble_sort(new.tolist())